﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace App.Validate
{
    public class StringLengthValidatorAttribute : ValidatorAttribute
    {
        public int LowerBound { get;  set; }
        public int UpperBound { get;  set; }

        public StringLengthValidatorAttribute(string messageTemplate)
            : base(messageTemplate)
        {
            this.LowerBound = int.MinValue;
            this.UpperBound = int.MaxValue;
        }

        public StringLengthValidatorAttribute(string messageTemplate, int lowerBound)
            : base(messageTemplate)
        {
            this.LowerBound = lowerBound;
            this.UpperBound = int.MaxValue;
        }

        public StringLengthValidatorAttribute(string messageTemplate, int lowerBound, int upperBound)
            : base(messageTemplate)
        {
            this.LowerBound = lowerBound;
            this.UpperBound = upperBound;
        }

        public override Validator CreateValidator()
        {
            return new StringLengthValidator(this.MessageTemplate, this.LowerBound, this.UpperBound);
        }
    }
}
